package com.neuedu.his.dao;

import com.neuedu.his.entity.ConstantItem;
import com.neuedu.his.entity.InspectItem;
import com.neuedu.his.framework.BaseDao;
import com.neuedu.util.JDBCUtil;

import java.util.List;

/**
 * 项目：      his
 * 类名:       InspectItemDao
 * 创建时间：  2020/12/23  8:43
 * 描述 :     用户数据访问层
 * 作者 :     张金山
 * QQ :     314649444
 * Site:      https://jshand.gitee.io
 */
public class InspectItemDao implements BaseDao<InspectItem> {


    @Override
    public List<InspectItem> selectList(String sql, Object... args) {
        return JDBCUtil.executeQuery(sql, InspectItem.class, args);
    }

    @Override
    public InspectItem selectById(Integer id) {
        String sql = " select * from inspect_item where id = ?";
        return JDBCUtil.getOne(sql, InspectItem.class, id);
    }

    @Override
    public boolean update(InspectItem checkItem) {

       String sql  = " UPDATE   inspect_item SET   name = ?,   fee = ? WHERE id = ? ";

        return JDBCUtil.executeUpdate(sql,
                checkItem.getName(),
                checkItem.getFee(),
                checkItem.getId()
        );
    }


    /**
     * 逻辑删除，没有真正删除数据
     * @param id
     * @return
     */
    @Override
    public boolean deleteById(Integer id) {

        String sql = " update  inspect_item set active = 0 where id  = ? ";

        return JDBCUtil.executeUpdate(sql,id);
    }

    @Override
    public boolean batchDel(String sql, Object... parm) {
        return false;
    }

    @Override
    public boolean insert(InspectItem checkItem) {
        String sql = " INSERT INTO inspect_item(   name,fee )  VALUES ( ?,? )  ";
        return JDBCUtil.executeUpdate(sql, checkItem.getName(),checkItem.getFee());
    }


}
